<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<div class="table-scrollable">
	<div class="order-nav">
		<a onclick="orderStatus()" style="font-size: 16px;">全部列表</a><a
			onclick="orderStatus('1')"
			style="font-size: 16px; margin-left: 10px;">待发货</a><a
			onclick="orderStatus('2')"
			style="font-size: 16px; margin-left: 10px;">已发货</a><a
			onclick="orderStatus('5')"
			style="font-size: 16px; margin-left: 10px;">已取消</a>
	</div>
	<table class="table table-striped table-hover table-info">
		<thead>
			<tr>
				<th>订单日期</th>
				<th>订单编号</th>
				<th>买家ID</th>
				<th>购买数量</th>
				<th>金额</th>
				<th>备注</th>
				<th>订单状态</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${page.result}" var="order" varStatus="vs"
				begin="${begin}" end="${end}">
				<tr>

					<td>${order.createtime }</td>
					<td><a
						onclick="add('/ordert/eBayOrderDetail?code=${order.code}')">${order.code }</a></td>
					<td>${order.person.uid }</td>
					<td>${order.count}</td>
					<td>${order.price}</td>
					<td>${order.description }</td>
					<td>${order.orderStatus.name }</td>

					<td><c:choose>
							<c:when test="${order.orderStatus.id==1 }">
								<a
									onclick="add('/deliverGoods/deliverGoods?orderCode=${order.code}')">手工发货</a>
							</c:when>
							<c:otherwise>
								<a onclick="toLogisticsInfo('${order.id}')">查看物流</a>
							</c:otherwise>
						</c:choose> <a onclick="add('/ordert/handOrderDetail?code=${order.code}')">查看
					</a><a onclick="update('/ordert/ordert?id=${order.id}')">编辑 </a><a
						onclick="cancelOrder('${order.id}')">取消订单</a></td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
</div>
<div class="pageination-panel">${page}</div>
<input id="startD" value="${startDate}" style="visibility: hidden;" />
<input id="endD" value="${endDate}" style="visibility: hidden;" />

<div class="modal fade" id="menuModal" tabindex="-1" role="basic"
	aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"
					aria-hidden="true"></button>
				<h4 class="modal-title">eBay订单信息导出</h4>
			</div>
			<div class="modal-body">

				<div style="margin: 0 auto; padding: 3% 3% 3% 5%;">

					<label>订单号&nbsp;</label><span id="orderid"
						style="color: #FF7F00; margin-left: 24px;"></span><br> <label>发货仓库&nbsp;</label><select
						style="margin-left: 10px; width: 200px;"><option>默认仓库</option></select><br>
					<label>快递公司&nbsp;</label><input type="text" placeholder="Fedex"
						style="width: 200px; margin-left: 10px;" /><br> <label>快递单号&nbsp;</label><input
						type="text" style="width: 200px; margin-left: 10px;" />
				</div>

			</div>
			<div class="modal-footer">
				<button type="button" class="btn blue" onclick="saveParentMenu()">确定</button>
				<button type="button" class="btn default" data-dismiss="modal">关闭</button>
			</div>
		</div>
	</div>
</div>


<div class="modal fade" id="pathMode" tabindex="-1" role="basic"
	aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"
					aria-hidden="true"></button>
				<h4 class="modal-title">选择项目目录</h4>
			</div>
			<div class="modal-body">
				<ul id="pathTree" class="ztree" style="margin-top: 0; width: 160px;"></ul>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn blue" onclick="saveProjectPath()">确定</button>
				<button type="button" class="btn default" data-dismiss="modal">关闭</button>
			</div>
		</div>
	</div>
</div>

<style type="text/css">
.order-nav {
	padding: 2% 2% 2% 0%;
}

.order-nav span {
	margin-left: 30px;
	font-size: 16px;
}

.order-nav span.active {
	color: #4F94CD;
}
</style>
<script type="text/javascript">
	var setting = {
		view : {
			selectedMulti : false
		},
		data : {
			simpleData : {
				enable : true
			}
		},
		callback : {
			beforeExpand : zTreeBeforeExpand
		}
	};

	function orderStatus(status) {

		var startDate = $("#startDate").val();
		var endDate = $("#endDate").val();

		if (startDate == "" || endDate == "") {

			startDate = $("#startD").val();
			endDate = $("#endD").val();

		}

		$.ajax({
			type : 'post',
			url : webRoot + '/ordert/eBayList',
			data : {
				"start" : startDate,
				"end" : endDate,
				"status" : status
			},
			dataType : 'html',
			success : function(data) {
				$(".panel-content").html(data);
			}
		});
	}

	function modelShow(plateformid) {

		var startDate = $("#startDate").val();
		var endDate = $("#endDate").val();

		if (startDate == "" || endDate == "") {

			startDate = $("#startD").val();
			endDate = $("#endD").val();

		}

		var urll = webRoot + "/ordert/exportExcel?plateformid=" + plateformid
				+ "&start=" + startDate + "&end=" + endDate;

		window.open(urll);

	}

	function pageControl(pageNo) {
		var url = '/ordert/nextPage'
		if (url.indexOf('?') > -1) {
			url += '&pageNo=' + pageNo;
		} else {
			url += '?pageNo=' + pageNo;
		}
		$.ajax({
			type : 'post',
			url : webRoot + url,
			dataType : 'html',
			success : function(data) {
				$(".panel-content").html(data);
			}
		});
	}

	function openFolder() {
		// 加载根目录结构
		$.ajax({
			type : 'post',
			url : '<c:url value="/generator/doExpandFileTree"></c:url>',
			dataType : 'json',
			success : function(data) {
				$.fn.zTree.init($("#pathTree"), setting, data);
			}
		});
		$('#pathMode').modal('show');
	}

	function zTreeBeforeExpand(treeId, treeNode) {
		// 加载子目录
		$.ajax({
			type : 'post',
			url : '<c:url value="/generator/doExpandFileTree"></c:url>',
			data : {
				parentNode : treeNode.id
			},
			dataType : 'json',
			success : function(data) {
				$.fn.zTree.getZTreeObj("pathTree").addNodes(treeNode, data);
			}
		});

	}
	function saveProjectPath() {
		var nodes = $.fn.zTree.getZTreeObj("pathTree").getSelectedNodes();
		alert(nodes[0].id)
		$('#projectPath').val(nodes[0].id);
		// 隐藏弹窗
		$('#pathMode').modal('hide');
	}

	function cancelOrder(id) {

		$.ajax({
			type : 'post',
			url : webRoot + '/ordert/ListFormsaves',
			data : {
				"id" : id,
				"orderStatusId" : 5
			},
			dataType : 'json',
			success : function(data) {
				search();
				$(".panel-search").show();
			}
		});

	}

	function toLogisticsInfo(orderid) {

		$.ajax({
			type : 'post',
			url : webRoot + '/webpage/shopping/Amazon/jdt.jsp',
			dataType : 'html',
			success : function(data) {
				$(".panel-content").html(data);
			}
		});

		$.ajax({
			type : 'post',
			url : webRoot + '/amazonorderslists/orderLogisticsInfo',
			data : {
				"orderid" : orderid
			},
			dataType : 'html',
			success : function(data) {
				$(".panel-search").hide();
				$(".panel-content").html(data);
			}
		});

	}
</script>